//
//  HXTabBarController.m
//  RomensSDK
//
//  Created by 王增战 on 2017/3/29.
//  Copyright © 2017年 孙博. All rights reserved.
//

#import "HXTabBarController.h"
//#import <Hyphenate/EMSDK.h>
#import <Hyphenate/EMConversation.h>
#import "ChatViewController.h"
#import "ConversationListController.h"
@interface HXTabBarController ()
{
    ConversationListController *_chatListVC;//消息列表
}
@end

@implementation HXTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}
#pragma mark -- 原mainViewController文件，可以移植过来
// 统计未读消息数
//-(void)setupUnreadMessageCount
//{
//    [[NSNotificationCenter defaultCenter] postNotificationName:@"setupUnreadMessageCount" object:nil];
//}

//- (void)jumpToChatList
//{
//    if ([self.navigationController.topViewController isKindOfClass:[ChatViewController class]]) {
//        
//        
//    }
//    else if(_chatListVC)
//    {
//        [self.navigationController popToViewController:self animated:NO];
//        [self setSelectedViewController:_chatListVC];
//    }
//}
//
//- (EMConversationType)conversationTypeFromMessageType:(EMChatType)type
//{
//    EMConversationType conversatinType = EMConversationTypeChat;
//    switch (type) {
//        case EMChatTypeChat:
//            conversatinType = EMConversationTypeChat;
//            break;
//        case EMChatTypeGroupChat:
//            conversatinType = EMConversationTypeGroupChat;
//            break;
//        case EMChatTypeChatRoom:
//            conversatinType = EMConversationTypeChatRoom;
//            break;
//        default:
//            break;
//    }
//    return conversatinType;
//}
//
//- (void)didReceiveLocalNotification:(UILocalNotification *)notification
//{
//    NSDictionary *userInfo = notification.userInfo;
//    if (userInfo)
//    {
//        if ([self.navigationController.topViewController isKindOfClass:[ChatViewController class]]) {
//            
//            
//        }
//        
//        NSArray *viewControllers = self.navigationController.viewControllers;
//        [viewControllers enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(id obj, NSUInteger idx, BOOL *stop){
//            if (obj != self)
//            {
//                if (![obj isKindOfClass:[ChatViewController class]])
//                {
//                    [self.navigationController popViewControllerAnimated:NO];
//                }
//                else
//                {
//                    NSString *conversationChatter = userInfo[kConversationChatter];
//                    ChatViewController *chatViewController = (ChatViewController *)obj;
//                    if (![chatViewController.conversation.conversationId isEqualToString:conversationChatter])
//                    {
//                        [self.navigationController popViewControllerAnimated:NO];
//                        EMChatType messageType = [userInfo[kMessageType] intValue];
//                        chatViewController = [[ChatViewController alloc] initWithConversationChatter:conversationChatter conversationType:[self conversationTypeFromMessageType:messageType]];
//                        switch (messageType) {
//                            case EMChatTypeChat:
//                            {
//                                NSArray *groupArray = [[EMClient sharedClient].groupManager getJoinedGroups];
//                                for (EMGroup *group in groupArray) {
//                                    if ([group.groupId isEqualToString:conversationChatter]) {
////                                            chatViewController.title = group.subject;
//                                        break;
//                                    }
//                                }
//                            }
//                                break;
//                            default:
////                                chatViewController.title = conversationChatter;
//                                break;
//                        }
//                        chatViewController.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStyleDone target:nil action:nil];
//                        [self.navigationController pushViewController:chatViewController animated:NO];
//                    }
//                    *stop= YES;
//                }
//            }
//            else
//            {
//                ChatViewController *chatViewController = (ChatViewController *)obj;
//                NSString *conversationChatter = userInfo[kConversationChatter];
//                EMChatType messageType = [userInfo[kMessageType] intValue];
//                chatViewController = [[ChatViewController alloc] initWithConversationChatter:conversationChatter conversationType:[self conversationTypeFromMessageType:messageType]];
//                switch (messageType) {
//                    case EMChatTypeGroupChat:
//                    {
//                        NSArray *groupArray = [[EMClient sharedClient].groupManager getJoinedGroups];
//                        for (EMGroup *group in groupArray) {
//                            if ([group.groupId isEqualToString:conversationChatter]) {
////                                chatViewController.title = group.subject;
//                                break;
//                            }
//                        }
//                    }
//                        break;
//                    default:
//                        //                        chatViewController.title = conversationChatter;
//                        break;
//                }
//                chatViewController.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStyleDone target:nil action:nil];
//                [self.navigationController pushViewController:chatViewController animated:NO];
//            }
//        }];
//    }
//    else if (_chatListVC)
//    {
//        [self.navigationController popToViewController:self animated:NO];
//        [self setSelectedViewController:_chatListVC];
//    }
//}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
